<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	template="/WEB-INF/templates/template.xhtml">

	<h:outputStylesheet>
		.rf-dt-import-ambito{
			width:500px;
		}
		.rf-fu{
			height: 100px;
			width:500px;
		}
	</h:outputStylesheet>

	<ui:define name="breadcrumb">
		<ui:include src="breadcrumb.xhtml" />
	</ui:define>
	<ui:define name="menu">
		<ui:include src="/user/menu.xhtml" />
	</ui:define>
	<ui:define name="title">#{messages.obraSocialImport}</ui:define>
	<ui:define name="content">
	    <h:form id="form">
			<rich:fileUpload fileUploadListener="#{obraSocialBean.processImportObraSocial}"
	            id="uploadOs" acceptedTypes="xls"
	            maxFilesQuantity="1"	            
	            uploadLabel="#{messages.importUpload}"
	            addLabel="#{messages.obraSocialImport}" 
			    clearAllLabel="#{messages.importEraseAll}"
			    clearLabel="#{messages.importErase}"
			    deleteLabel="#{messages.importErase}"> 
			    <a4j:ajax event="uploadcomplete" execute="@none" render="importedOSTable" />
	        </rich:fileUpload>
		<rich:dataTable value="#{obraSocialBean.importedOSList}" var="result"
			id="importedOSTable" styleClass="rf-dt-import-ambito">
				
      			<rich:column>
      				<f:facet name="header">
				       <h:selectBooleanCheckbox id="selectAll" 
				       		title="#{messages.selectAll}" 
				       		valueChangeListener="#{obraSocialBean.selectAll}">
							<a4j:ajax event="change" 
								execute="@this"
								render="importedOSTable"/>
				        </h:selectBooleanCheckbox>
      				</f:facet>
      				<h:selectBooleanCheckbox value="#{result.selected}" />
      			</rich:column>
      			<rich:column>
      				<f:facet name="header">
      					<h:outputText value="#{messages.obraSocialNombre}"/>
      				</f:facet>
      				<h:outputText value="#{result.entity.name}"/>
      			</rich:column>
      			<rich:column>
      				<f:facet name="header">
      					<h:outputText value="#{messages.obraSocialSigla}"/>
      				</f:facet>
      				<h:outputText value="#{result.entity.sigla}"/>
      			</rich:column>
	
			<f:facet name="footer">
				<rich:dataScroller />
			</f:facet>        		
		</rich:dataTable>
		<h:commandButton action="#{obraSocialBean.importarObrasSociales}" 
			value="#{messages.import}"/>	        
	    </h:form>
	</ui:define>	
</ui:composition>